home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.01 Jan 90 / DLL Source Code / Flash.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-27  |  1.9 KB  |  71 lines  |  [TEXT/MPS ]

  1. /************************************************/
  2. /*                  Sample DLL's                */
  3. /*       Copyright © Vincent Parsons 1989.      */
  4. /************************************************/
  5. /*    DLL code for MPW C 3.0 or THINK C 4.0     */
  6. /*       with Excel for the Macintosh 2.2       */
  7. /*             and Microsoft C 5.1              */
  8. /*          with Excel for Windows 2.1          */
  9. /************************************************/
  10. /* Flash is an example of direct manipulation   */
  11. /* of the screen from a DLL. The DLL inverts    */
  12. /* the window rectangle twice the input         */
  13. /* parameter times.                             */
  14. /************************************************/
  15. /*   =REGISTER("SampDLLs","Flash","AI")         */
  16. /*   for both the Mac and the PC.               */
  17. /************************************************/
  18.  
  19. #ifdef applec
  20.  
  21. #include <Types.h>
  22. #include <Memory.h>
  23. #include <OSUtils.h>
  24. #include <QuickDraw.h>
  25.  
  26. #elif MSDOS
  27. #include <windows.h>
  28.  
  29. #endif
  30.  
  31. #ifdef THINK_C
  32. pascal unsigned short main(short flashCount);    /* prototype */
  33.  
  34. pascal unsigned short main(flashCount)
  35. short flashCount;
  36.  
  37. #elif applec
  38. pascal unsigned short Flash(short flashCount)
  39.  
  40. #elif MSDOS
  41. unsigned short far pascal Flash(short flashCount)
  42. #endif
  43. {
  44.     short    again;
  45. #if THINK_C | applec
  46.     GrafPtr    port;
  47.     
  48.     GetPort(&port);
  49.     for (again = 1; again <= flashCount; again++) {
  50.         InvertRect(&port->portRect);
  51.         InvertRect(&port->portRect);
  52.     }
  53. #elif MSDOS    
  54.     HWND    myWindowHandle;
  55.     HDC    myDisplayContext;
  56.     RECT    myRect;
  57.     
  58.     myWindowHandle = GetActiveWindow();
  59.     myDisplayContext = GetWindowDC(myWindowHandle);
  60.     GetWindowRect(myWindowHandle, (LPRECT)&myRect);
  61.     for (again = 1; again <= flashCount; again++) {
  62.         InvertRect(myDisplayContext, (LPRECT)&myRect);
  63.         InvertRect(myDisplayContext, (LPRECT)&myRect);
  64.     }
  65.     ReleaseDC(myWindowHandle,myDisplayContext);
  66. #endif    
  67.     return(again);
  68. }
  69.  
  70. /************************************************/
  71.